package com.ybkj.o2o.zhuanche.manager.impl;

import com.ybkj.o2o.zhuanche.common.DataGrid;
import com.ybkj.o2o.zhuanche.common.query.OrderReviewQuery;
import com.ybkj.o2o.zhuanche.entity.OrderReview;
import com.ybkj.o2o.zhuanche.manager.OrderReviewManager;
import com.ybkj.o2o.zhuanche.service.OrderReviewService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class DefaultOrderReviewManager implements OrderReviewManager {
  @Autowired
  private OrderReviewService orderReviewService;

  @Override
  public OrderReview findByOrderIdAndAppKey(OrderReviewQuery orderReviewQuery) {

    return orderReviewService.findByOrderIdAndAppKey(orderReviewQuery);
  }

  @Override
  @Transactional(rollbackFor = Exception.class)
  public int insert(OrderReview orderReview) {
    return orderReviewService.insert(orderReview);
  }
  
  @Override
  public DataGrid<OrderReview> findByDriver(OrderReviewQuery orderReviewQuery) {
    List<OrderReview> list = orderReviewService.findByDriver(orderReviewQuery);
    
    Long count = orderReviewService.countByDriver(orderReviewQuery);

    DataGrid<OrderReview> dataGrid = new DataGrid<>();
    dataGrid.setRows(list);
    dataGrid.setTotal(count);

    return dataGrid;
    
  }

  @Override
  @Transactional(rollbackFor = Exception.class)
  public void deleteById(Long id, String appKey) {
    orderReviewService.deleteById(id, appKey);
  }

  @Override
  public OrderReview findOne(OrderReviewQuery orderReviewQuery) {
    
    return orderReviewService.findOne(orderReviewQuery);
  }


}
